#ifndef D_PLANE_H
#define D_PLANE_H

#include <math.h>
#include <helpers\math\vector3.h>

namespace DelGE
{
	namespace Helpers
	{
		namespace Math
		{
			struct Plane
			{
				Vector3 normal;
				float fDistanceFromOrigin;

				Plane();
				~Plane();

				Vector3 GetNormal() const;
				float GetDistanceFromOrigin() const;

				void SetNormal(const Vector3& rNormal);
				void SetDistanceFromOrigin(float fDistanceFromOrigin);

				void Normailize();
			};

			inline Vector3 Plane::GetNormal() const
			{
				return this->normal;
			}

			inline float Plane::GetDistanceFromOrigin() const
			{
				return this->fDistanceFromOrigin;
			}

			inline void Plane::SetNormal(const Vector3& rNormal)
			{
				this->normal = rNormal;
			}

			inline void Plane::SetDistanceFromOrigin(float fDistanceFromOrigin)
			{
				this->fDistanceFromOrigin = fDistanceFromOrigin;
			}

			inline void Plane::Normailize()
			{
				float length = sqrt((this->normal[0] * this->normal[0]) + (this->normal[1] * this->normal[1]) + (this->normal[2] * this->normal[2]));

				this->normal[0] /= length;
				this->normal[1] /= length;
				this->normal[2] /= length;
				this->fDistanceFromOrigin /= length;
			}
		}
	}
}

#endif